package com.ruoyi.code.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import com.ruoyi.app.R
import com.ruoyi.code.base.viewbinding.base.ActivityBinding
import com.ruoyi.code.base.viewbinding.base.ActivityBindingDelegate
import com.ruoyi.code.utils.ActivityManager
import com.zackratos.ultimatebarx.ultimatebarx.navigationBar
import com.zackratos.ultimatebarx.ultimatebarx.statusBar

abstract class BaseBindingActivity<VB : ViewBinding> : AppCompatActivity(),
    ActivityBinding<VB> by ActivityBindingDelegate() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentViewWithBinding()
        statusBar {
            fitWindow = true
            light = true
            colorRes = R.color.white
        }
        navigationBar {
            fitWindow = true
            colorRes = R.color.white
        }

        ActivityManager.instance.addActivity(this)

        initView()
        initData()

    }

    abstract fun initView()

    abstract fun initData()

    override fun onDestroy() {
        super.onDestroy()
        ActivityManager.instance.removeActivity(this)
    }
}